using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MediaPortal.GUI.Rss
{
    public partial class AzureusSetupForm : Form
    {
        public AzureusSetupForm()
        {
            InitializeComponent();

            this.LoadSettings();
        }

        private void LoadSettings()
        {
            MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings("MediaPortal.xml");

            //string azureusFlag = xmlreader.GetValue("torrents", "Azureus.enabled");

            //this.cbxAzureus.Checked = (azureusFlag == "true");

            //this.groupBox1.Enabled = this.cbxAzureus.Checked;

            this.tbxURL.Text = xmlreader.GetValue("torrents", "Azureus.url");
            if (this.tbxURL.Text.Length == 0)
            {
                this.tbxURL.Text = @"http://127.0.0.1:6884/process.cgi";
            }

            this.tbxSeconds.Text = xmlreader.GetValue("torrents", "Azureus.seconds");
            if (this.tbxSeconds.Text.Length == 0)
            {
                this.tbxSeconds.Text = "10";
            }
        }

        private void SaveSettings()
        {
            MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings("MediaPortal.xml");
            xmlwriter.SetValue("torrents", "Azureus.url", this.tbxURL.Text);
            xmlwriter.SetValue("torrents", "Azureus.seconds", this.tbxSeconds.Text);

            //if (this.cbxAzureus.Checked)
            //{
            //    xmlwriter.SetValue("torrents", "Azureus.enabled", "true");
            //}
            //else
            //{
            //    xmlwriter.SetValue("torrents", "Azureus.enabled", "false");
            //}
        }

        private void bttnOK_Click(object sender, EventArgs e)
        {
            this.SaveSettings();
            this.Close();
        }

        private void bttnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        //private void cbxAzureus_CheckedChanged(object sender, EventArgs e)
        //{
        //    this.groupBox1.Enabled = this.cbxAzureus.Checked;
        //}

        //private void groupBox1_Enter(object sender, EventArgs e)
        //{

        //}
    }
}